// 导入UI组件
import CountUI from "../components/Count"
// 导入connect 用于 连接 UI组件和 store
import { connect } from "react-redux"

// 导入action
import {createIncrementAction, createDecrementAction, createAsyncIncrementAction} from "../redux/countAction"

// 传递状态到ui组件
const mapStateToProps = state => ({sum: state})

// 传递操作状态的方法到ui组件
const mapDispatchToProps = dispatch => ({
    increment: value => dispatch(createIncrementAction(value)),
    decrement: value => dispatch(createDecrementAction(value)),
    incrementAsync: (value, time) => dispatch(createAsyncIncrementAction(value, time))
})

// 导出  生成的 容器组件
export default connect(mapStateToProps,mapDispatchToProps )(CountUI)
